package com.wang.service.impl;

import com.wang.dao.MemberInfoMapper;
import com.wang.entity.MemberInfo;
import com.wang.service.MemberInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Classname MemberInfoServiceImpl
 * @Description TODO
 * @Date 2023/11/14 9:33
 * @Created by pc
 */
@Service
public class MemberInfoServiceImpl implements MemberInfoService {
    @Autowired
    private MemberInfoMapper memberInfoMapper;
    @Override
    public List<MemberInfo> findAll() {
        return memberInfoMapper.findAll();
    }

    @Override
    public MemberInfo findById(Long id) {
        return memberInfoMapper.findById(id);
    }

    @Override
    public Map<String, Object> update(MemberInfo memberInfo) {
        Map<String,Object> map = new HashMap<>();
        Integer result = memberInfoMapper.update(memberInfo);
        if(result > 0){
            map.put("status",200);
            map.put("msg","更新成功");
        }else{
            map.put("status",400);
            map.put("msg","更新失败");
        }
        return map;
    }

    @Override
    public Map<String, Object> del(Long id) {
        Map<String,Object> map = new HashMap<>();
        Integer result = memberInfoMapper.del(id);
        if(result > 0){
            map.put("status",200);
            map.put("msg","删除成功");
        }else{
            map.put("status",400);
            map.put("msg","删除失败");
        }
        return map;
    }
}
